package com.quyeying.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName MybatisPlusUtil
 * @Description TODO
 * @Author skx
 * @Date 2021/9/9
 */
@Component
public class PageUtil {

    /**
     * 封装mybatis plus分页数据,更友好的返回给前端
     */
    public static Map<String, Object> pageUtil(Page page) {

        Map<String, Object> pageMap = new HashMap<>(3);
        pageMap.put("records", page.getRecords());
        pageMap.put("total", page.getTotal());
        pageMap.put("pages", page.getPages());
        return pageMap;
    }
}
